<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | create by allen.qiang
// +----------------------------------------------------------------------


/**
 * 角色 操作功能
 * @package  htdocs
 * @subpackage  quanliadmin
 * create by allen.qiang
 */

quanli_require('module/base/system/sysRole.class.php');

class pa_roleList {
	
	public function execute() {

        if (isset($_REQUEST['operFlg']) && is_numeric($_REQUEST['operFlg']) && $_REQUEST['operFlg'] > 0) {

            switch ($_REQUEST['operFlg']){

                case 1: //角色列表页
                    $this->roleList();
                    break;

                default:
                    backendError();
                    break;

            }

        } else {

            backendError();

        }

	}

    /**
     * 角色列表页
     */
    private function roleList() {

		global $G_PGLOB;

        quanli_require('module/base/project/permission.class.php');

		//实例角色类
		$sysRole = new sysRole();

        //实例权限类
        $permission = new permission();

		//获取角色组信息
        $arg_array = array();
        $role_group_array = $sysRole->searchRoleGroup( $arg_array );
        if (!$role_group_array) {
            backendError('角色组信息不存在，请先新增角色组信息');
        }

        //查询所有权限组信息
        $permission_group_array = $permission->searchPermissionGroup();
        if (!$permission_group_array) {
            backendError('没有权限信息，请先录入权限信息');
        }

        foreach($permission_group_array as &$group) {

            //查询权限组下的权限信息
            $arg_array = array(
                'permissionGroupID' => $group['permissionGroupID']
            );
            $permission_array = $permission->searchPermission( $arg_array );
            $group['permission_list'] = $permission_array;

        }

		$G_PGLOB->smarty->assign_by_ref('role_group_array', $role_group_array);
		$G_PGLOB->smarty->assign_by_ref('permission_group_array', $permission_group_array);

        $G_PGLOB->smarty->assign('edit_permission', $G_PGLOB->has_permission(6));

		$G_PGLOB->smarty->display('system/roleList.tpl');

	}

}